"use strict";
/**
 * @name order
 * 订单处理
 */

//转账，目前仅支持支付宝
module.exports = function () {
    let opensdk = this.get("opensdk","string");
    let orderid = this.get("orderid","string");
    if(!opensdk ||!orderid){
        return this.error("args empty");
    }
    return Promise.resolve(1).then(()=>{
        let keys = ["_id","key","status","setting"];
        let opensdkModel = this.model.branch('opensdk',this.branch);
        return opensdkModel.get(opensdk,keys);
    }).then(ret=>{
        if(!ret){
            return this.error('opensdk_not_exist',opensdk);
        }
        if(ret['status']>1){
            return this.error('opensdk_disabled',opensdk);
        }
        this.opensdk = ret;
        return this.library.call(this,"opensdk/handle","cash",this.req.body);
    })
}